Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor point_properties and property_container #509

Open
wants to merge 4 commits into
base: issue-493
Choose a base branch
from
Open

Conversation

icui
Copy link
Collaborator

@icui icui commented Feb 24, 2025

Description

  • Internally stores values in point_properties in an array
  • Merge all views in properties_container into a single view.
  • Accessing point property now requires a function call, e.g. point_property.mu()
  • Derived properties (e.g. rho_vp) are now computed on the fly

Issue Number

Closes #489

Checklist

Please make sure to check developer documentation on specfem docs.

  • I ran the code through pre-commit to check style
  • My code passes all the integration tests
  • I have added sufficient unittests to test my changes
  • I have added/updated documentation for the changes I am proposing
  • I have updated CMakeLists to ensure my code builds
  • My code builds across all platforms

@icui
Copy link
Collaborator Author

icui commented Feb 24, 2025

It seems that computing the derived properties on the fly instead of storing them has no performance impact, probably we should use this implementation instead.

  KOKKOS_INLINE_FUNCTION value_type kappa_inverse() const {
    return (static_cast<value_type>(1.0)) / kappa();
  }

Copy link
Collaborator

@Rohit-Kakodkar Rohit-Kakodkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes

using Base::Base;
constexpr static int _counter = __COUNTER__;

DEFINE_CONTAINER(rho_inverse)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is nuts.

: public impl::impl_properties_container<
specfem::element::medium_tag::acoustic,
specfem::element::property_tag::isotropic, 2> {
using Base =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use base_type here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

template <specfem::element::medium_tag MediumTag,
specfem::element::property_tag PropertyTag, int N>
struct impl_properties_container {
using view_type = typename Kokkos::View<type_real ****, Kokkos::LayoutLeft,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think view type shoudl be Kokkos::View<type_real ***[N], Kokkos::LayoutLeft, ...> since we know the value of N at compile time.

Copy link
Collaborator

@lsawade lsawade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful

DEFINE_PROP(c12) ///< @f$ c_{12} @f$
DEFINE_PROP(c23) ///< @f$ c_{23} @f$
DEFINE_PROP(c25) ///< @f$ c_{25} @f$
DEFINE_PROP(rho) ///< Density @f$ \rho @f$
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Counter works, because at each first property use you store its value and subtract it. Neat.

using Base::Base;
constexpr static int _counter = __COUNTER__;

DEFINE_CONTAINER(rho_inverse)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is nuts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants